package com.wuliwu.autoapi.service;

import com.wuliwu.autoapi.bean.User;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class UserService {

    public List<User> list(String username){
        List<User> users = new ArrayList<>();
        users.add(new User(1, "user1", new Date()));
        users.add(new User(2, "user2", new Date()));
        users.add(new User(3, "user3", new Date()));

        if (!StringUtils.isEmpty(username)){
            users = users.stream().filter(user -> user.getUsername().contains(username)).collect(Collectors.toList());
        }
        return users;
    }
}
